package com.zhumiao.weixindev.util;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.client.RestTemplate;

public class WeixinUtil {
    public static void main(String[] args) {
        System.out.println(getToken());
    }
    //获取token
    public static String getToken(){
        RestTemplate template = new RestTemplate();
        String accessToken = template.getForObject("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxbac5b98a6880b265&secret=f03a5de4e4d720b94814cf7998747fe5",
                String.class);
        JSONObject jsonObject = JSONObject.parseObject(accessToken);
        String token = jsonObject.getString("access_token");
        return token;
    }
}
